<?php
session_cache_expire(999999999);
if (!isset($_SESSION)) {
    session_start();
}
//FC2BAA1A20B4D5190B122B383D7449FD
$status = $_GET['status'];
if ($status == 0) {
    $l_ngaygiaodich = $l_ngaygiaodich0;
    $l_ngayphathanh = $l_ngayphathanh0;
    $l_thoigiangiaodich = $l_thoigiangiaodich0;
}
if ($status == 1) {
    $l_ngaygiaodich = $l_ngaygiaodich1;
    $l_ngayphathanh = $l_ngayphathanh1;
    $l_thoigiangiaodich = $l_thoigiangiaodich1;
}
include 'invoicetax.php';
$soluonggiaodich = 0;
$tonggiacungcap = 0;
$tongthue = 0;
$tongtien = 0;
$tongcong = 0;
$tongtieninput = 0;
$_SESSION['invoice_arr'] = array();
$_SESSION['input_invoice'] = array();
unset($_SESSION['months']);
unset($_SESSION['years']);
$ob = new invoicetax();
$ob->newinvoicetax();
if (!isset($_REQUEST['months'])) {
    if (!isset($_SESSION['months']))
        $_SESSION['months'] = date("m");

    $ob->orday = date("d");
    $ob->ormonth = $_SESSION['months'];

    if (!isset($_REQUEST['years'])) {
        if (!isset($_SESSION['years']))
            $_SESSION['years'] = date("Y");
        $ob->oryear = $_SESSION['years'];
    }else {
        $_SESSION['years'] = $_REQUEST['years'];
        $ob->oryear = $_REQUEST['years'];
    }
} else {
    $ob->ormonth = $_REQUEST['months'];
    $_SESSION['months'] = $_REQUEST['months'];

    if (!isset($_REQUEST['years'])) {
        if (!isset($_SESSION['years']))
            $_SESSION['years'] = date("Y");
        $ob->oryear = $_SESSION['years'];
    }else {
        $_SESSION['years'] = $_REQUEST['years'];
        $ob->oryear = $_REQUEST['years'];
    }

    if ($_SESSION['months'] == date('m') && $_SESSION['years'] == date('Y')) {
        $ob->orday = date('d');
    } else {
        $ob->orday = 1;
    }
}

//echo $_SESSION['months'].'-'.$_SESSION['years'];

$songay = date("t", mktime(0, 0, 0, $ob->ormonth, 1, $ob->oryear));


$_SESSION['input_invoice'][] = $ob;

$sqlinvoice = mysql_query("SELECT or_order_tax.* 
from or_order_tax 
where month(or_order_tax.order_time)='" . $_SESSION['months'] . "' 
		and year(or_order_tax.order_time)='" . $_SESSION['years'] . "' and is_status='" . $status . "' 
ORDER BY or_order_tax.order_time,or_order_tax.order_time_transaction,or_order_tax.order_cusname,or_order_tax.order_content;");
?>
<style>
    <!--
    * {padding:0; margin:0;}
    -->
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.price_format.1.7.js"></script>
<script type="text/javascript" src="js/jquery.price_format.1.7.min.js"></script>
<link rel="stylesheet" type="text/css" href="admin/css/jsDatePick_ltr.min.css" />
<script type="text/javascript" src="admin/css/jsDatePick.min.1.4.js"></script>
<link	href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" />
<script type="text/javascript" src="js/jquery.autocomplete.js"></script>
<script language="javascript" src="js/cal2.js"></script>
<style type="text/css">
    .content_menu_expand{
        position:absolute; 
        right:-5px;
        top:20px;
        z-index:999;
        background-color: #ffffff;
        -moz-border-radius: 7px;
        -webkit-border-radius: 7px;
        color: #000000;
        width:300px; 
        max-height:180px;
        overflow:auto;
    }


    .passul{padding-left:0; border:1px solid black}
    .bgkhac {background: #eee;}
    .passul ul{padding:0px}
    .passul ul li {color:#474747; font-size:12px;padding: 5px 0;padding-left:5px;list-style: none;}
    .passul ul li:hover { background: #0A246A;color:white;text-decoration: none;list-style: none;}


</style>

<script type="text/javascript">
    function loadCal(){
        var sl=document.getElementById("soluongphantu").value;
        for(i=0;i<Number(sl);i++){
            addCalendar("Calendar"+i, "<?php echo $l_choosedate; ?>", "txttimetran"+i, "f_ac_elisoft_order_tax");
        }
        setWidth(90, 1, 15, 1);
        setFormat("yyyy-mm-dd");
    }

    function clickCustomer(gt,vitri,type){
        document.getElementById("txtcusname"+vitri).value=gt;
        $('#content_menu_expand'+vitri).hide();
	
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp2=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp2.onreadystatechange=function(){
            if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                document.getElementById("temptb").innerHTML=xmlhttp2.responseText;
                document.getElementById("txtitem"+vitri).focus();
                document.getElementById("txtitem"+vitri).select();										    	
            }
        }
        xmlhttp2.open("POST","ajax/acc/or_change_invoice_tax_inputtext.php?type="+type+"&value="+encodeURIComponent(gt)+"&vitri="+vitri,true);
        xmlhttp2.send();
    }
    window.onload = function(){

        new JsDatePick({
            useMode:2,
            target:"txttimetran0",
            dateFormat:"%Y-%m-%d"
        });

    };
	
    $(document).ready(function(){
        $('#txtquantity0').priceFormat({
            prefix: '',
            centsLimit: 0,
            centsSeparator: '',
            thousandsSeparator: ','
		
        });

        Load();
	
    });

    function Load(){
    	var sl=document.getElementById("soluongphantu").value;
    	for(var i=0;i<sl;i++){
	    	new JsDatePick({
	            useMode:2,
	            target:"txttimetran"+i,
	            dateFormat:"%Y-%m-%d"
	        });
	    	new JsDatePick({
	            useMode:2,
	            target:"txttimepayment"+i,
	            dateFormat:"%Y-%m-%d"
	        });
    	}
        var count=document.getElementById("soluongphantu").value;
        if(count==""){
            count=0;
        }
        for(i=0;i<count;i++){
		
            $("#txtcusname"+i).autocomplete("operations/rpc_search_invoice_tax.php", {
                selectFirst: true
			
            });
		
            $('#content_menu_expand'+i).hide();
            $(document).click(function() {
                for(var j=0;j<count;j++){
                    $("#content_menu_expand"+j).hide();
                }
            });
            $('#content_menu_expand'+i).click(function(e) {
                e.stopPropagation();
            });
		
            $('#menu_expand'+i).click(function(event) {
			
                var id=event.target.id;
                j=id.split("menu_expand");
			
                if ($('#content_menu_expand'+j[1]).is(":hidden")) {
			
                    $('#content_menu_expand'+j[1]).show();
                    for(var k=0;k<count;k++){
                        if(k!=j[1])
                            $("#content_menu_expand"+k).hide();
                    }
                }
                else {
                    $('#content_menu_expand'+j[1]).hide();
                }
                return false;
            });
		
        }
        loadCal();
    }

    function formatnumagain(soluong){
        for(i=0;i<soluong;i++){
            $('#txtquantity'+i).priceFormat({
                prefix: '',
                centsLimit: 0,
                centsSeparator: '',
                thousandsSeparator: ','
            });

        }
    }

    function add(status){
        var etax = document.getElementById("months");
        var txttax = etax.options[etax.selectedIndex].value;
        var etax1 = document.getElementById("years");
        var txtnam = etax1.options[etax1.selectedIndex].value;
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function(){
            if (xmlhttp.readyState==4 && xmlhttp.status==200){
                document.getElementById("showinput").innerHTML=xmlhttp.responseText;
                var sl=document.getElementById("soluongphantu").value;
                formatnumagain(sl);
                Load();
            }
        }
        xmlhttp.open("GET","ajax/acc/or_add_invoice_tax.php?addtype=1&thang="+txttax+"&nam="+txtnam+"&status="+status,true);
        xmlhttp.send();
    }

    function deleteclick(vitri,status){
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function(){
            if (xmlhttp.readyState==4 && xmlhttp.status==200){
                document.getElementById("showinput").innerHTML=xmlhttp.responseText;
                var sl=document.getElementById("soluongphantu").value;
                formatnumagain(sl);
                Load();
            }
        }
        xmlhttp.open("GET","ajax/acc/or_add_invoice_tax.php?addtype=0&vitri="+vitri+"&status="+status,true);
        xmlhttp.send();
    }
    function chRed(ele,vitri,type){
    	var gt=document.getElementById(type+vitri).checked;
    	var value=0;
    	if(gt==true){
        	value=1;
        	$(ele).parent().parent().attr('style','background-color:#FF9999');
        }else{
        	$(ele).parent().parent().attr('style','background-color:#d0d8e8');
        	value=0;
        }
    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp2=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp2.onreadystatechange=function(){
            if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                document.getElementById("temptb").innerHTML=xmlhttp2.responseText;
            }
        }
        xmlhttp2.open("POST","ajax/acc/or_change_red.php?type="+type+"&value="+value+"&vitri="+vitri,true);
        xmlhttp2.send();
    }
    function chText(gt,vitri,type){
        if(type=="txtday"){
            var vsongay=document.getElementById("songay").value;
            if((Number(gt)>0) && (Number(gt)<= Number(vsongay))){
			
                if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp2=new XMLHttpRequest();
                }else{// code for IE6, IE5
                    xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp2.onreadystatechange=function(){
                    if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                        document.getElementById("temptb").innerHTML=xmlhttp2.responseText;
                    }
                }
                xmlhttp2.open("POST","ajax/acc/or_change_invoice_tax_inputtext.php?type="+type+"&value="+encodeURIComponent(gt)+"&vitri="+vitri,true);
                xmlhttp2.send();
            }else{
                alert("<?php echo $l_check_inovice_tax_time; ?>");
            }
        }else{
            if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp2=new XMLHttpRequest();
            }else{// code for IE6, IE5
                xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp2.onreadystatechange=function(){
                if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                    document.getElementById("temptb").innerHTML=xmlhttp2.responseText;
                }
            }
            
            xmlhttp2.open("POST","ajax/acc/or_change_invoice_tax_inputtext.php?type="+type+"&value="+encodeURIComponent(gt)+"&vitri="+vitri,true);
            xmlhttp2.send();
        }
    }

    function chQuan(gt,vitri,type){
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp2=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp2.onreadystatechange=function(){
            if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                document.getElementById("vintotal"+vitri).innerHTML=xmlhttp2.responseText;
                $.ajax({url:"ajax/acc/or_change_invoice_tax_vinsum.php?",success:function(result){
                        $("#vinsum").html(result);
                    }});
            }
        }
        xmlhttp2.open("POST","ajax/acc/or_change_invoice_tax_number.php?type="+type+"&value="+encodeURIComponent(gt)+"&vitri="+vitri,true);
        xmlhttp2.send();
    }


    function chRice(gt,vitri,type){
        if(gt=='')
            gt='0';
        if(gt=='-')
            gt='0';
        if(gt=='-0' || gt=='0-')
            gt='-0';

        var b=gt.split(',');
        if(b.length>1){
            gt='';
            for(i=0;i<b.length;i++){
                gt=gt+b[i];
            }
        }
	
        var a=gt.split('-');
        if(a.length==2){
            am='-';
            gt='';
            for(i=0;i<a.length;i++){
                gt=gt+a[i];
            }
            gt=Number(gt);
            gt=am+gt;
        }else if(a.length==3){
            gt='';
            for(i=0;i<a.length;i++){
                if(a[i]!='-')
                    gt=gt+a[i];
            }
            gt=Number(gt);
        }else{
	
            gt=Number(gt);
        }

        nStr =gt+ '';
        x = nStr.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? '.' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1)) {
            x1 = x1.replace(rgx, '$1' + ',' + '$2');
        }
        gt=x1+x2;
	
        document.getElementById("txtrice"+vitri).value=gt;
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp2=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp2.onreadystatechange=function(){
            if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
											  
                document.getElementById("vintax"+vitri).innerHTML=xmlhttp2.responseText;
                $.ajax({url:"ajax/acc/or_change_invoice_tax_vintotal.php?vitri="+vitri,success:function(result){
											    	
                        var id="#vintotal"+vitri;
                        //alert(result);
                        $(id).html(result);
                        $.ajax({url:"ajax/acc/or_change_invoice_tax_vinsum.php?",success:function(result){
                                $("#vinsum").html(result);
                            }});
                    }});
                var sl=document.getElementById("soluongphantu").value;
                formatnumagain(sl);
            }
        }
        xmlhttp2.open("POST","ajax/acc/or_change_invoice_tax_number.php?type="+type+"&value="+gt+"&vitri="+vitri,true);
        xmlhttp2.send();
    }

    function chTax(gt,vitri,type){

        if(gt=='')
            gt='0';
        if(gt=='-')
            gt='0';
        if(gt=='-0' || gt=='0-')
            gt='-0';

        var b=gt.split(',');
        if(b.length>1){
            gt='';
            for(i=0;i<b.length;i++){
                gt=gt+b[i];
            }
        }
	
        var a=gt.split('-');
        if(a.length==2){
            am='-';
            gt='';
            for(i=0;i<a.length;i++){
                gt=gt+a[i];
            }
            gt=Number(gt);
            gt=am+gt;
        }else if(a.length==3){
            gt='';
            for(i=0;i<a.length;i++){
                if(a[i]!='-')
                    gt=gt+a[i];
            }
            gt=Number(gt);
        }else{
	
            gt=Number(gt);
        }

        nStr =gt+ '';
        x = nStr.split('.');
        x1 = x[0];
        x2 = x.length > 1 ? '.' + x[1] : '';
        var rgx = /(\d+)(\d{3})/;
        while (rgx.test(x1)) {
            x1 = x1.replace(rgx, '$1' + ',' + '$2');
        }
        gt=x1+x2;
	
        document.getElementById("vointax"+vitri).value=gt;
	
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp2=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp2.onreadystatechange=function(){
            if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                document.getElementById("otxtrice"+vitri).innerHTML=xmlhttp2.responseText;
                $.ajax({url:"ajax/acc/or_change_invoice_tax_vintotal.php?vitri="+vitri,success:function(result){
                        var id="#vintotal"+vitri;
                        $(id).html(result);
                        $.ajax({url:"ajax/acc/or_change_invoice_tax_vinsum.php?",success:function(result){
                                $("#vinsum").html(result);
                                var sl=document.getElementById("soluongphantu").value;
                                formatnumagain(sl);
                            }});
                    }});
            }
        }
        xmlhttp2.open("POST","ajax/acc/or_change_invoice_tax_number.php?type="+type+"&value="+encodeURIComponent(gt)+"&vitri="+vitri,true);
        xmlhttp2.send();
    }

    function save(status){
        var sl=document.getElementById("soluongphantu").value;
        if(sl>0){
            hoi=confirm("<?php echo $l_areyousure; ?>");
            if(hoi==true){
                var etax = document.getElementById("months");
                var txtthang = etax.options[etax.selectedIndex].value;
			
                var etax1 = document.getElementById("years");
                var txtnam = etax1.options[etax1.selectedIndex].value;
			
                if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp2=new XMLHttpRequest();
                }else{// code for IE6, IE5
                    xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp2.onreadystatechange=function(){
                    if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                        document.getElementById("showlist").innerHTML=xmlhttp2.responseText;
                        var loi=document.getElementById("convoi").value;
                        if(loi=="l_themthanhcong"){
                            $.ajax({url:"ajax/acc/or_invoice_tax_resetadd.php?thang="+txtthang+"&nam="+txtnam+"&status="+status,success:function(result){
                                   $("#showinput").html(result);
                                   var sl=document.getElementById("soluongphantu").value;
                                    formatnumagain(sl);
                                    alert("<?php echo $l_themthanhcong; ?>");
                                    Load();
                                }});
                        }else{
                            alert(loi);
                        }
                    }
                }
                xmlhttp2.open("POST","ajax/acc/or_save_invoice_tax.php?thang="+txtthang+"&nam="+txtnam+"&status="+status,true);
                xmlhttp2.send();
            }
        }else{
            alert("<?php echo $l_not_input_inovice_tax; ?>");
        }
    }
    function enterTable(e,value,count,co){
        var key = window.event ? e.keyCode : e.which;

        if (key == 13 || key == 8 || key == 46  || key == 37 || key == 39 || key == 45 || co == '0') {
            if(key==13){
                var i = 0;
                var j = 0;
                var listID = new Array();
                for(i = 0; i < count;i++){
                    listID = listID.concat(["txtday"+i,"txtcusname"+i,"txtitem"+i,"txtrice"+i,"vointax"+i,"txttimetran"+i,"txttimepayment"+i,"txtmemo"+i]);	
                }
                for (j = 0; j < listID.length; j++){	
                    if (listID[j] == value) {	
                        if (j == listID.length - 1) {
                            return false;
                        }
                        document.getElementById(listID[j + 1]).focus();
                        document.getElementById(listID[j + 1]).select();
                        return false; 
                    }
                }
			
                return false;
            }else
                return true;	
        } else if ( key < 48 || key > 57 ) {
            return false;
        }
        else return true;
				
    }

    function chDate(gt,vitri,type){
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp2=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp2.onreadystatechange=function(){
            if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                document.getElementById("temptb").innerHTML=xmlhttp2.responseText;
            }
        }
        xmlhttp2.open("POST","ajax/acc/or_change_invoice_tax_inputtext.php?type="+type+"&value="+encodeURIComponent(gt)+"&vitri="+vitri,true);
        xmlhttp2.send();
    }

    function delOneRow(id,status){
        var etax = document.getElementById("months");
        var txtthang = etax.options[etax.selectedIndex].value;
        var etax1 = document.getElementById("years");
        var txtnam = etax1.options[etax1.selectedIndex].value;
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp2=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp2.onreadystatechange=function(){
            if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                document.getElementById("showlist").innerHTML=xmlhttp2.responseText;
                var loi=document.getElementById("convoi").value;
                if(loi=="l_xoathanhcong"){
                    alert("<?php echo $l_xoathanhcong; ?>");
                    var iddel=document.getElementById("idedit").value;
                    if(iddel==id){
                        $.ajax({url:"ajax/acc/or_invoice_tax_edit_reset.php?thang="+txtthang+"&nam="+txtnam+"&status="+status,success:function(result){
                                $("#inadd").html(result);
                                var sl=document.getElementById("soluongphantu").value;
                                formatnumagain(sl);
                                Load();
                            }});
                    }
                }else{
                    alert(loi);
                    Load();
                }
            }
        }
        xmlhttp2.open("POST","ajax/acc/or_save_invoice_tax.php?id="+id+"&type=del&thang="+txtthang+"&nam="+txtnam+"&status="+status,true);
        xmlhttp2.send();
    }

    function editOneRow(vitri,id,status){
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp2=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp2.onreadystatechange=function(){
            if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                document.getElementById("inadd").innerHTML=xmlhttp2.responseText;
                var sl=document.getElementById("soluongphantu").value;
                formatnumagain(sl);
                Load();
            }
        }
        xmlhttp2.open("POST","ajax/acc/or_invoice_tax_edit.php?id="+id+"&vitri="+vitri+"&status="+status,true);
        xmlhttp2.send();
    }

    function cancelEdit(status){
        var etax = document.getElementById("months");
        var txtthang = etax.options[etax.selectedIndex].value;
        var etax1 = document.getElementById("years");
        var txtnam = etax1.options[etax1.selectedIndex].value;
	
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp2=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp2.onreadystatechange=function(){
            if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                document.getElementById("inadd").innerHTML=xmlhttp2.responseText;
                var sl=document.getElementById("soluongphantu").value;
                formatnumagain(sl);
                Load();
            }
        }
        xmlhttp2.open("POST","ajax/acc/or_invoice_tax_edit_reset.php?thang="+txtthang+"&nam="+txtnam+"&status="+status,true);
        xmlhttp2.send();
    }

    function editOk(status){
        var etax = document.getElementById("months");
        var txtthang = etax.options[etax.selectedIndex].value;
        var etax1 = document.getElementById("years");
        var txtnam = etax1.options[etax1.selectedIndex].value;
        var sl=document.getElementById("soluongphantu").value;
      

        
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp2=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp2.onreadystatechange=function(){
            if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                document.getElementById("showlist").innerHTML=xmlhttp2.responseText;
                var loi=document.getElementById("convoi").value;
                if(loi=="l_capnhatthanhcong"){
                    alert("<?php echo $l_capnhatthanhcong; ?>");
                    $.ajax({url:"ajax/acc/or_invoice_tax_edit_reset.php?thang="+txtthang+"&nam="+txtnam+"&status="+status,success:function(result){
                            $("#inadd").html(result);
                            var sl=document.getElementById("soluongphantu").value;
                            formatnumagain(sl);
                            Load();
                        }});
                }else{
                    alert(loi);
                    Load();
                }
            }
        }
        xmlhttp2.open("POST","ajax/acc/or_save_invoice_tax.php?type=up&thang="+txtthang+"&nam="+txtnam+"&status="+status,true);
        xmlhttp2.send();
    }

    function dayclick(id,value){
        document.getElementById(id).value=value;
        document.getElementById(id).style.backgroundColor="#ccffdd";  
    }

    function dayclickok(value){
        var id=document.getElementById("pop_id_name").value;
        var ten="txtday"+id;
        document.getElementById(ten).value=value;
        document.getElementById(ten).style.backgroundColor="#ffffff"; 
        if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp2=new XMLHttpRequest();
        }else{// code for IE6, IE5
            xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp2.onreadystatechange=function(){
            if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
                document.getElementById("temptb").innerHTML=xmlhttp2.responseText;
                document.getElementById("txtcusname"+id).focus();
            }
        }
        xmlhttp2.open("POST","ajax/acc/or_change_invoice_tax_inputtext.php?type=txtday&value="+encodeURIComponent(value)+"&vitri="+id,true);
        xmlhttp2.send(); 
    }
</script>
<?php
$vyear = date("Y");
?>
<div  class="title" style="padding-top: 5px;font-weight: bold;"><?php echo $l_accountant; ?>&rarr; <?php if($status==0)echo $l_Invoice_thu;else echo $l_Invoice_chi; ?> &rarr; <?php echo $l_invoice_tax; ?></div>
<div class="content_code">

    <input type="hidden" name="content" value="ac_elisoft_order_tax_content" />
    <input type="hidden" name="songay" id="songay" value="<?= $songay ?>" />
    <div class="approval-right">		
        <form action="accountant-search.php?content=ac_elisoft_order_tax_content&status=<?= $status ?>" method="post" name="f_ac_elisoft_order_tax" id="f_ac_elisoft_order_tax">
            <table border="0" width="150px" class="ftable" cellspacing="1">
                <tr>
                    <th style="height:30px"><?php echo $l_month; ?></th>
                    <th style="height:30px;">
                        <select onchange="document.f_ac_elisoft_order_tax.submit()" style="width:50px;height:24px;font-size:12px;text-align:center;valign:middle;" id="months" name="months">
                            <?php for ($i = 1; $i <= 12; $i++) { ?>
                                <option value="<?= $i ?>"  
                                <?php
                                if ($_SESSION['months'] == $i) {
                                    ?>
                                            selected="selected"
                                            <?php
                                        }
                                        ?>
                                        >
                                            <?php echo $i ?>
                                </option>
                            <?php } ?>
                        </select> 
                    </th>
                    <th style="height:30px"><?php echo $l_year; ?></th>
                    <th style="height:30px;">
                        <select onchange="document.f_ac_elisoft_order_tax.submit()" style="width:60px;height:24px;font-size:12px;text-align:center;valign:middle;" id="years" name="years">
                            <?php for ($i = 2012; $i <= ($vyear+7); $i++) { ?>
                                <option value="<?= $i ?>"  
                                <?php
                                if ($_SESSION['years'] == $i) {
                                    ?>
                                            selected="selected"
                                            <?php
                                        }
                                        ?>
                                        >
                                            <?php echo $i ?>
                                </option>
                            <?php } ?>
                        </select> 
                    </th>
                </tr>
            </table>
        </form>
        <div style="clear:both"></div>
        <div style="position:relative" id="showlist">
            <table cellpadding="0" cellspacing="1" width="100%" border="0" class="ftable ">
                <tr >
                    <th style="width:10px"></th>
                    <th style="width:10px"><?= $l_no ?></th>
                    <th style="width:30px"><?= $l_month ?></th>
                    <th style="width:30px"><?= $l_days ?></th>
                    <th style="width:220px"><?= $l_customer ?></th>
                    <th style="width:30%"><?= $l_product_item ?></th>
                    <th style="width:50px;display: none;"><?= $l_quantity ?></th>
                    <th style="width:90px"><?= $l_Supply_price ?></th>
                    <th style="width:90px"><?= $l_vat ?></th>
                    <th style="width:90px"><?= $l_amount ?></th>
                    <th style="width:90px;"><?= $l_thoigiangiaodich ?></th> 
                    <th style="width:90px;<?php if($status==0) echo 'display: none'?>" ><?= $l_payment ?></th> 
                    <th style="width:10%"><?= $l_memo ?></th>
                </tr>
                <?php
                if (mysql_num_rows($sqlinvoice) > 0) {
                    $soluonggiaodich = 0;
                    $tonggiacungcap = 0;
                    $tongthue = 0;
                    $tongtien = 0;
                    $soluonggiaodich1 = 0;
                    $tonggiacungcap1 = 0;
                    $tongthue1 = 0;
                    $tongtien1 = 0;

                    $vitri = 0;
                    $temp = "";
                    $i = 0;
                    while ($rin = mysql_fetch_array($sqlinvoice)) {
                        $inobject = new invoicetax();
                        $ktdate = getdate(strtotime($rin[order_time]));
                        $inobject->Instance($rin['orderid'], $rin['order_time'], $ktdate['mon'], $ktdate['mday'], $ktdate['year'], $rin['order_cus'], $rin['order_content'], 
                        					$rin['order_quantity'], $rin['order_supply_rice'], $rin['order_tax'], $rin['order_total'], $rin['order_time_transaction'], 
                        					$rin['is_status'], $rin['user_create'], $rin['date_create'], $rin['order_memo'], $rin['status']);
                        $inobject->setCusname($rin['order_cusname']);
                        $inobject->setPayment($rin['order_time_payment']);
						$inobject->setRED($rin['red']);
                        
                        ?>
                        <tr style="padding:3px;<?php if($status==1){if($inobject->red==1) echo 'background: #FF9999;';if($inobject->red==0) echo 'background: #d0d8e8;';}?>" >

                            <td>
                                <img onclick="var hoi=confirm('<?=$l_confirm_deleteproject?>'); if(hoi==true){delOneRow(<?= $inobject->orderid ?>,<?= $status ?>);}" src="images/del.png" style="width:20px;height:20px;cursor:pointer;" title="<?php echo $l_delete; ?>" />
                            </td>
                            <td style="padding: 5px;cursor:pointer;" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)"><p style="width: 20px"><?= ($vitri + 1) ?></p></td>
                            <td style="cursor:pointer;" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)"><p style="width: 20px"><?= $inobject->ormonth ?></p></td>
                            <td style="cursor:pointer;" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)"><p style="width: 20px"><?= $inobject->orday ?></p></td>
                            <td style="cursor:pointer;text-align:left;padding-left:3px;" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)"><p style="width: 200px"><?php echo $inobject->cusname; ?></p></td>
                            <td style="cursor:pointer;text-align:left;padding-left:3px;" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)"><p style="min-width: 200px"><?= $inobject->order_content ?></p></td>
                            <td style="display: none;cursor:pointer;" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)"><p style="width: 30px"><?= number_format($inobject->order_quantity) ?></p></td>
                            <td style="cursor:pointer;text-align:right;padding-right:3px;" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)"><p style="width: 90px"><?= number_format($inobject->order_suplly_rice) ?></p></td>
                            <td style="cursor:pointer;text-align:right;padding-right:3px;" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)"><p style="width: 90px"><?= number_format($inobject->order_tax) ?></p></td>
                            <td style="cursor:pointer;text-align:right;padding-right:3px;" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)"><p style="width: 90px"><?= number_format($inobject->order_total) ?></p></td>
                            <td style="cursor:pointer;" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)">
                                <p style="width: 80px"> <?php
                if ($inobject->nstatus == 1)
                    echo "-";
                else
                    echo $inobject->order_time_transaction;
                        ?>
                                </p>
                            </td>
                            
                            <td style="cursor:pointer;<?php if($status==0) echo 'display: none'?>" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)">
                                <p style="width: 80px"> <?php echo $inobject->order_time_payment;?>
                                </p>
                            </td>
                            <td style="cursor:pointer;" onclick="editOneRow(<?= $vitri ?>,<?= $inobject->orderid ?>,<?= $status ?>)"><p style="min-width: 120px"><?= $inobject->order_memo ?></p></td>

        <?php
        $vitri++;
        $soluonggiaodich++;
        $tonggiacungcap +=$inobject->order_suplly_rice;
        $tongthue +=$inobject->order_tax;
        $tongtien +=$inobject->order_total;


        ?></tr><?php
                    $_SESSION['invoice_arr'][$rin[orderid]] = $inobject;
                }
    ?>
                  
    <?php
}else {
    ?>
                    <tr><td colspan="12" style="height:30px;text-align:left;padding-left:20px;"><?php echo $l_list_emplty; ?></td></tr>
                <?php } ?>
                <tr class="coltr2" style="height:30px;font-weight:bold;">
                    <td colspan="5"><?php echo $l_all . '-' . $l_month; ?> : <font color="red"><?php echo $_SESSION['months'] ?></font>  -  <?php echo $l_co; ?>  <font color="blue"><?php echo number_format($soluonggiaodich); ?></font> <?php echo $l_giaodich; ?></td>
                    <td></td>
                    <td style="display: none;"></td>
                    <td style="text-align:right;padding-right:3px;"><?php echo number_format($tonggiacungcap); ?></td>
                    <td style="text-align:right;padding-right:3px;"><?php echo number_format($tongthue); ?></td>
                    <td style="text-align:right;padding-right:3px;"><?php echo number_format($tongtien); ?></td>
                    <td colspan="3"></td>
                </tr>            
            </table>       
        </div> 
        <div id="inadd" style="position:relative">
            <div>
                <form action="" method="post" name="formexcel" enctype="multipart/form-data">
                    <input name="fileexcel" type="file" value="ad" onchange="document.formexcel.submit()" style="width:250px;height:24px;" />
                </form>
            </div>
            <div>
                <input onclick="add(<?=$status?>);" type="button" value="+" id="btadd" name="btadd" class="btnupbg btnupload" style="width:50px;font-size:20px;background: #4f81bd;"/> 
            </div>
<?php
if (isset($_FILES["fileexcel"])) {
    include 'CheckTime1.php';
    include 'Classes/simplexlsx.class.php';
    date_default_timezone_set('Europe/London');
    $inputFileName = $_FILES['fileexcel']['tmp_name'];
    unset($_SESSION['input_invoice']);
    $_SESSION['input_invoice'] = array();



    $xlsx = new SimpleXLSX($inputFileName);
    // sheets numeration: 1,2,3....
    $xmlWorkBook = $xlsx->getXMLWorkBook();
    $vitri = 0;
    foreach ($xlsx->sheets() as $keysheet => $ws) {
        $loadedSheetName = '' . $xlsx->getWorksheetName($xmlWorkBook, $keysheet - 1);
        $sheetdate = '';
        $curR = 0;
        foreach ($ws->sheetData->row as $row) {
            $curC = 0;
            $vcheck = 0;
            $ob = new invoicetax();
            $ob->newinvoicetax();

            if (!isset($_REQUEST['years'])) {
                if (!isset($_SESSION['years']))
                    $_SESSION['years'] = date("Y");
                $ob->oryear = date("Y");
            }else {
                $_SESSION['years'] = $_REQUEST['years'];
                $ob->oryear = $_REQUEST['years'];
            }

            foreach ($row->c as $keyc => $c) {
                if ($curR > 0) {
                    if ($curC == 0)
                        $ob->oryear = $xlsx->value($c);
                    if ($curC == 1)
                        $ob->ormonth = $xlsx->value($c);
                    if ($curC == 2)
                        $ob->orday = $xlsx->value($c);
                    if ($curC == 3)
                        $ob->cusname = $xlsx->value($c);
                    if ($curC == 4)
                        $ob->order_content = $xlsx->value($c);
                    //if($curC==4)
                    //$ob->order_quantity=$xlsx->value($c);
                    $ob->order_quantity = 1;
                    if ($curC == 5) {
                        if (trim($xlsx->value($c)) == "-" || trim($xlsx->value($c)) == "") {
                            $ob->order_suplly_rice = 0;
                            echo "<script>alert('\"F" . ($curR + 1) . "\" 에 레코드가 형식에 맞지 않습니다.');</script>";
                        }
                        else
                            $ob->order_suplly_rice = $xlsx->value($c);
                    }
                    if ($curC == 6) {
                    	
                        if (trim($xlsx->value($c)) == "-" || trim($xlsx->value($c)) == "") {
                            $ob->order_tax = 0;
                            //echo "<script>alert('\"G".($curR+1)."\" 에 레코드가 형식에 맞지 않습니다.');</script>";
                        }
                        else
                            $ob->order_tax = $xlsx->value($c);
                    }
                    if ($curC == 7) {
                        if (trim($xlsx->value($c)) == "-" || trim($xlsx->value($c)) == "" ) {
                            $ob->order_total = 0;
                            echo "<script>alert('\"H" . ($curR + 1) . "\" 에 레코드가 형식에 맞지 않습니다.');</script>";
                        }
                        else
                            $ob->order_total = $xlsx->value($c);
                    }
                    if ($curC == 8) {
                        if ($xlsx->value($c) != '')
                            if (is_numeric($xlsx->value($c))) {
                                $ob->order_time_transaction = date('Y-m-d', mktime(0, 0, 0, 1, $xlsx->value($c) - 1, 1900));
                            } else {
                                $ob->order_time_transaction = "";
                                echo "<script>alert('\"I" . ($curR + 1) . "\" 에 레코드가 형식에 맞지 않습니다.');</script>";
                            }
                    }
                    if ($curC == 9)
                        $ob->order_memo = $xlsx->value($c);
                }
                $curC++;
            }
            if ($curR > 0)
                $_SESSION['input_invoice'][] = $ob;

            $curR++;
            $vitri++;
        }
    }
}
?>
            <div style="position:relative" id="showinput">
                <table cellpadding="0" cellspacing="1" width="100%" border="0" class="ftable" >
                    <tr >
                        <th style="width:10px"></th>
                        <?php if($status==1){?><th style="width:10px"></th><?php }?>
                        <th style="width:10px"><?= $l_no ?></th>
                        <th style="width:30px"><?= $l_month ?></th>
                        <th style="width:30px"><?= $l_days ?></th>
                        <th style="width:200px"><?= $l_customer ?></th>
                        <th style="width:40%"><?= $l_product_item ?></th>
                        <th style="width:50px;display: none"><?= $l_quantity ?></th>
                        <th style="width:90px"><?= $l_Supply_price ?></th>
                        <th style="width:90px"><?= $l_vat ?></th>
                        <th style="width:90px"><?= $l_amount ?></th>
                        <th style="width:90px"><?= $l_thoigiangiaodich ?></th> 
                        <th style="width:90px;<?php if($status==0) echo 'display: none'?>"><?= $l_payment ?></th> 
                        <th style="min-width:120px"><?= $l_memo ?></th> 
                    </tr>
<?php
if (isset($_SESSION['input_invoice']) && count($_SESSION['input_invoice']) > 0) {
    for ($i = 0; $i < count($_SESSION['input_invoice']); $i++) {
        $inobject = unserialize(serialize($_SESSION['input_invoice'][$i]));
        ?>
                            <tr >
                                <td><img onclick="deleteclick(<?=$i?>,<?= $status ?>);" src="images/del.png" style="width:20px;height:20px;cursor:pointer;" title="<?php echo $l_delete; ?>" /></td>
                                <?php if($status==1){?><td><input type="checkbox" id="<? echo "red" . $i ?>" name="red[]"  <?php if($inobject->red==1) echo 'checked="checked"';?> onchange="chRed(this,<?= $i ?>,'red');"></td><?php }?>
                                <td><p style="width: 20px"><?= ($i + 1) ?></p></td>
                                <td><p style="width: 20px"><?= $inobject->ormonth ?></p></td>
                                <td>
                                    <a href="#?w=200" rel="popup_name3" onclick="popuploadbel_invoice_tax_day(this,<?= $i ?>);" class="poplight"><input type="text" readonly="readonly" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']); ?>,'1')" id="<? echo "txtday" . $i ?>" name="vday[]" style="height: 24px; width: 30px; border: 1px solid #c4c0c9;line-height: 24px;font-size:12px;text-align:center;"	value="<?= $inobject->orday ?>" autocomplete="off"  /></a>
                                </td>

                                <td style="padding:3px">
                                    <div style="position:relative; ">
                                        <div style="float:left;">
                                            <input  type="text" size="30" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']); ?>,'0')" onchange="chText(this.value,<?= $i ?>,'txtcusname');" onkeyup="chText(this.value,<?= $i ?>,'txtcusname');" id="<? echo "txtcusname" . $i ?>" name="vcusname[]" value="<?= $inobject->cusname ?>"  style="height: 24px; width:220px; border: 1px solid #c4c0c9;font-size: 12px;" autocomplete="off"; />
                                                    <div class="suggestionsBox" id="suggestions" style="display:none;">
                                                <img src="images/upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
                                                <div class="suggestionList" id="autoSuggestionsList">
                                                    &nbsp;
                                                </div>
                                            </div> 						
                                        </div>
                                        <div style=" float:left; position:relative; margin-top: 5px; margin-left: -21px ">
                                            <img alt="" src="images/arrow-down.png" id="<? echo "menu_expand" . $i; ?>" >
                                            <div id="<? echo "content_menu_expand" . $i; ?>" class="passul content_menu_expand" style="display:none;text-align: left;width: 220px;">
                                                <ul>
        <?php
        $sql = "select ac_customer.CustomerName from ac_customer where ac_customer.Activest=1 ORDER BY ac_customer.CustomerName ASC";
        $result = mysql_query($sql);
        if ($result) {
            $j = 0;
            while ($row = mysql_fetch_array($result)) {
                ?>
                                                            <li onmouseover="this.style.cursor='pointer'"  onmouseout="this.style.cursor='default'" onclick="clickCustomer('<?= $row['CustomerName'] ?>','<?= $i ?>','txtcusname')" 
                                                            <?php
                                                            if ($j % 2 != 0) {
                                                                ?>
                                                                    class="bgkhac"
                                                                <?php
                                                            }
                                                            ?>
                                                                > <?php echo $row['CustomerName']; ?></li>
                                                                <?php
                                                                $j++;
                                                            }
                                                        }
                                                        ?>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>


                                </td>
                                <td>
                                    <input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']); ?>,'0')" onchange="chText(this.value,<?= $i ?>,'txtitem');" onkeyup="chText(this.value,<?= $i ?>,'txtitem');" id="<? echo "txtitem" . $i ?>" name="vitem[]" style="height: 24px; width: 98%; border: 1px solid #c4c0c9;line-height: 24px;font-size:12px;"	value="<?= $inobject->order_content ?>" autocomplete="off"  />
                                </td>
                                <td style="display: none">
                                    <input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']); ?>,'1')" onchange="chQuan(this.value,<?= $i ?>,'txtquantity');" onkeyup="chQuan(this.value,<?= $i ?>,'txtquantity');" id="<? echo "txtquantity" . $i ?>" name="vquantity[]" style="height: 24px; width:30px; border: 1px solid #c4c0c9;line-height: 24px;text-align:center;font-size:12px;"	value="<?= $inobject->order_quantity ?>" autocomplete="off"  />
                                </td>
                                <td  id="<? echo "otxtrice" . $i ?>">
                                    <input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']); ?>,'1')" onchange="chRice(this.value,<?= $i ?>,'txtrice');" onkeyup="chRice(this.value,<?= $i ?>,'txtrice');" id="<? echo "txtrice" . $i ?>" name="vrice[]" style="height: 24px; width: 90px; border: 1px solid #c4c0c9;line-height: 24px;text-align:right;padding-right:3px;font-size:12px;"	value="<?= number_format($inobject->order_suplly_rice) ?>" autocomplete="off"  />
                                </td>

                                <td id="<? echo "vintax" . $i ?>">
                                    <input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']); ?>,'1')" onchange="chTax(this.value,<?= $i ?>,'vintax');" onkeyup="chTax(this.value,<?= $i ?>,'vintax');" id="<? echo "vointax" . $i ?>" name="ovointax[]" style="height: 24px; width: 90px; border: 1px solid #c4c0c9;line-height: 24px;text-align:right;padding-right:3px;font-size:12px;"	value="<?= number_format($inobject->order_tax) ?>" autocomplete="off"  />
                                </td>
                                <td style="text-align:right;padding-right:3px;" id="<? echo "vintotal" . $i ?>"><p style="width: 90px"><?= number_format($inobject->order_total) ?></p></td>
                                <td style="padding:3px">
                                    <input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']); ?>,'0')" onfocus="chText(this.value,<?= $i ?>,'txttimetran');" onkeyup="chText(this.value,<?= $i ?>,'txttimetran');" id="<? echo "txttimetran" . $i ?>" name="vtimetran[]" style="height: 24px; width: 90px; border: 1px solid #c4c0c9;line-height: 24px;text-align:center;font-size:12px;"	value="<?= $inobject->order_time_transaction ?>" autocomplete="off"  />
                                    <!--  <small><a style="font-size: 12px" href="javascript:showCal('<?php echo "Calendar" . $i; ?>')"><img src="images/calendars.png" title="<?php echo $l_choosedate; ?>" /></a></small>-->

                                </td>
                                <td style="padding:3px;<?php if($status==0) echo 'display: none'?>">
                                    <input type="text"   onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']); ?>,'0')" onfocus="chText(this.value,<?= $i ?>,'txttimepayment');" onkeyup="chText(this.value,<?= $i ?>,'txttimepayment');" id="<? echo "txttimepayment" . $i ?>" name="vtimepayment[]" style="height: 24px; width: 90px; border: 1px solid #c4c0c9;line-height: 24px;text-align:center;font-size:12px;"	value="<?= $inobject->order_time_payment ?>" autocomplete="off"  />
                                </td>
                                <td style="padding:3px">
                                    <input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($_SESSION['input_invoice']); ?>,'0')" onfocus="chText(this.value,<?= $i ?>,'txtmemo');" onkeyup="chText(this.value,<?= $i ?>,'txtmemo');" id="<? echo "txtmemo" . $i ?>" name="vmemo[]" style="height: 24px; width: 120px; border: 1px solid #c4c0c9;line-height: 24px;text-align:center;font-size:12px;"	value="<?= $inobject->order_memo ?>" autocomplete="off"  />
                                </td>
                            </tr>
        <?php
        $tongtieninput +=$inobject->order_total;
        $tongcong +=$inobject->order_total;
    }
} else {
    ?>
                        <tr><td colspan="11" style="height:30px;text-align:left;padding-left:20px;"><?php echo $l_list_emplty; ?></td></tr>
                    <?php } ?>
                    <tr class="coltr2" style="height:30px;font-weight:bold;">
                        <td colspan="5"></td>
                        <?php if($status==1){?><td></td><?php }?>
                        <td></td>
                        <td style="display: none"></td>
                        <td></td>
                        <td></td>
                        <td style="text-align:right;padding-right:3px;" id="vinsum"><?php echo number_format($tongtieninput); ?></td>
                        <td>(yyyy-mm-dd)</td>
                        <td style="<?php if($status==0) echo 'display: none'?>">(yyyy-mm-dd)</td>
                        <td></td>
                    </tr>            
                </table>       

                <div id="temptb"><input type="hidden" value="<?= count($_SESSION['input_invoice']) ?>" id="soluongphantu" /></div>

            </div>   
            <div style="width:100%;text-align:center;padding-top:20px;" ><input onclick="save('<?= $status ?>');" type="button" style="background: #4f81bd;" value="<?= $l_save ?>" class="btnupbg btnupload" /></div>      
        </div>  


<?php
$mthu = array("Su", "Mo", "Tu", "We", "Th", "Fr", "Sa");
?>
        <div id="popup_name3" class="popup_block">
        <?php
        $t = $_SESSION["months"];
        $n = $_SESSION["years"];
        $tenthang = $t . " - " . $n;
        $ntt = date("t,", mktime(0, 0, 0, $t, 1, $n));
        $vt = date("w", mktime(0, 0, 0, $t, 1, $n));
        $ngay = 1;
        ?>
            <span
                style="background: #4F81BD; color: #FFFFFF; display: block; padding: 5px 0 5px 10px;"><?php echo $tenthang; ?>
            </span>
            <input name="pop_id_name" id="pop_id_name" type="hidden" />
            <table align='center' width='100%' border='1' bgcolor='#eeffff' style='font-size:11px;border-collapse: collapse;'>
<?php
for ($i = 0; $i < 7; $i++) {
    ?>
                    <tr align='center' style='height:20px;'>
                    <?php
                    for ($j = 0; $j < count($mthu); $j++) {
                        if ($i == 0) {
                            ?>
                                <td style='width:20px'><font color='green'><b><?= $mthu[$j] ?></b></font></td>
                                <?php
                            } else {
                                if ($i == 1) {
                                    if (($j == $vt) and ($ngay <= $ntt)) {
                                        if ($j == 0) {
                                            ?>
                                            <td><lable class="iclose" onclick="dayclickok(<?= $ngay ?>)" style="cursor:pointer;color:red;font-weight:bold;"><?= $ngay ?></lable></td>
                                            <?php
                                        } else {
                                            ?>
                                        <td><lable class="iclose" onclick="dayclickok(<?= $ngay ?>)" style="cursor:pointer;"><?= $ngay ?></lable></td>
                                        <?php
                                    }
                                    $vt++;
                                    $ngay++;
                                } else {
                                    ?>
                                    <td></td>
                                    <?php
                                }
                            } else {
                                $vt = 0;
                                if ($ngay <= $ntt) {
                                    if ($j == 0) {
                                        ?>
                                        <td><lable class="iclose" onclick="dayclickok(<?= $ngay ?>)" style="cursor:pointer;color:red;font-weight:bold;"><?= $ngay ?></lable></td>
                                        <?php
                                    } else {
                                        ?>
                                        <td><lable class="iclose" onclick="dayclickok(<?= $ngay ?>)" style="cursor:pointer;"><?= $ngay ?></lable></td>
                                        <?php
                                    }
                                    $ngay++;
                                    $vt++;
                                } else {
                                    ?>
                                    <td></td>
                                    <?php
                                }
                            }
                        }
                    }
                    ?>			
                    </tr>
                    <?php
                }
                ?>
            </table>
        </div>
    </div>
</div>